Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schism: Fix stmp attributes in sflux files. #178

Merged
merged 1 commit into from
Apr 8, 2024
Merged

schism: Fix stmp attributes in sflux files. #178

merged 1 commit into from
Apr 8, 2024

Conversation

pmav99
Copy link
Collaborator

@pmav99 pmav99 commented Mar 27, 2024

No description provided.

@pmav99
Copy link
Collaborator Author

pmav99 commented Mar 27, 2024

I think the units for time is also wrong. It should be

        float time(time) ;
                time:long_name = "Time" ;
                time:standard_name = "time" ;
                time:units = "days since 2001-01-01" ;
                time:base_date = 2001, 1, 1, 0 ;

while it is set like this:

	double time(time) ;
		time:long_name = "Time" ;
		time:standard_name = "time" ;
		time:base_date = 2018LL, 10LL, 1LL, 0LL ;
		time:units = "2018-10-01" ;

The relevant code is:

udate = pd.to_datetime(date).strftime("%Y-%m-%d")
bdate = pd.to_datetime(date).strftime("%Y %m %d %H").split(" ")
tlist = (ar.time.data - pd.to_datetime([udate]).values).astype("timedelta64[s]") / 3600.0
tlist = tlist.astype(float) / 24.0
bdate = [int(q) for q in bdate[:3]] + [0]
sout = xr.Dataset(
{
"prmsl": (["time", "nx_grid", "ny_grid"], ar[p].data),
"uwind": (["time", "nx_grid", "ny_grid"], ar[u].data),
"vwind": (["time", "nx_grid", "ny_grid"], ar[v].data),
"spfh": (["time", "nx_grid", "ny_grid"], zero),
"stmp": (["time", "nx_grid", "ny_grid"], zero),
"lon": (["nx_grid", "ny_grid"], xx),
"lat": (["nx_grid", "ny_grid"], yy),
},
coords={"time": tlist},
)
sout.attrs = {
"description": "Schism meteo data",
"history": "pyposeidon",
"source": "netCDF4 python module",
}
sout.time.attrs = {
"long_name": "Time",
"standard_name": "time",
"base_date": bdate,
"units": udate,

@pmav99 pmav99 merged commit 7024f29 into master Apr 8, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant